package com.tender.controller;

import com.alibaba.fastjson.JSON;
import com.tender.annotations.DecryptionTag;
import com.tender.annotations.EncryptionTag;
import com.tender.common.Result;
import com.tender.request.UserRequest;
import com.tender.request.SecretRequest;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/secret")
public class SecretController {

    @PostMapping("/decrypt")
    public Result<String> decrypt(@DecryptionTag @RequestBody SecretRequest request) {
        System.out.println(JSON.toJSONString(request));
        String str = "this is a beautiful girl";
        return Result.of(str);
    }

    @PostMapping("/decrypt/valid")
    @EncryptionTag
    public Result<String> decryptAndValid(@DecryptionTag @RequestBody @Valid UserRequest request) {
        System.out.println(JSON.toJSONString(request));
        String str = "this is my handsome friend";
        return Result.of(str);
    }

}
